import compileAttribute from './compileAttribute.js'
import compileTextNode from './compileTextNode.js'

/*
 * @Author: zengwj
 * @Date: 2022-08-10 10:22:37
 * @LastEditors: zengwj
 * @LastEditTime: 2022-08-10 15:04:56
 * @Description:
 */
export default function compileNode(nodes, vm) {
	for (let i = 0, len = nodes.length; i < len; i++) {
		const node = nodes[i]
		//元素节点
		if (node.nodeType === 1) {
			compileAttribute(node, vm)
			compileNode([...node.childNodes], vm)
		} else if (node.nodeType === 3 && node.textContent.match(/{{(.*)}}/)) {
			compileTextNode(node, vm)
		}
	}
}
